import request from "../../../utils/request";

enum API {
  getUserInfoUrl = "/admin/acl/user/",
  getUserInfoByIdUrl = "/admin/acl/user/get/",
  saveUserInfoUrl = "/admin/acl/user/save",
  delUserUrl = "/admin/acl/user/remove/",
  updateUserUrl = "/admin/acl/user/update",
  getAllRolesUrl = "/admin/acl/user/toAssign/",
  assignRolesForUserUrl = "/admin/acl/user/doAssignRole",
  delBatchUserUrl = "/admin/acl/user/batchRemove",
}

export const reqGetUserInfo = (page: number, limit: number, param?: any) =>
  request.get(API.getUserInfoUrl + `${page}/${limit}`, { params: param });

export const reqSaveUserInfo = (userInfo: any) =>
  request.post(API.saveUserInfoUrl, userInfo);

export const reqDelUser = (id: number) => request.delete(API.delUserUrl + id);

export const reqDelBatchUser = (idList: any) =>
  request.delete(API.delBatchUserUrl, idList);

export const reqGetUserInfoById = (id: number) =>
  request.get(API.getUserInfoByIdUrl + id);
export const reqUpdateUser = (userInfo: any) =>
  request.put(API.updateUserUrl, userInfo);

export const reqGetAllRoles = (id: number) =>
  request.get(API.getAllRolesUrl + id);

export const reqAssignRolesForUser = (rolesInfo: any) =>
  request.post(API.assignRolesForUserUrl, rolesInfo);
